//
//  ViewController.m
//  BannarPic
//
//  Created by dllo on 16/2/24.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "listModel.h"
#import "BannarCell.h"
#import "BannarView.h"

@interface ViewController ()
@property(nonatomic,strong)NSMutableArray *myArr;
@property(nonatomic,strong)UICollectionView *myCollectionView;
@property(nonatomic,strong)BannarView *bannarView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.myArr = [NSMutableArray array];
    [self getData];
    
   self.bannarView = [[BannarView alloc] initWithFrame:CGRectMake(0, 100, WIDTH, 300)];
    [self.view addSubview:_bannarView];
    
}
- (void)getData{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    //AFN有些类型不支持,添加下面一句代码,支持大部分返回数据格式
    [manager.responseSerializer setAcceptableContentTypes:[NSSet setWithObjects:@"text/html", @"application/json", @"text/json", @"text/javascript",@"text/html",@"text/css", @"text/plain", @"application/x-javascript", @"application/javascript",nil]];
    
    [manager GET:@"http://mobile.ximalaya.com/m/super_explore_index2?device=iPhone&picVersion=9&scale=2" parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        
        NSDictionary *dic = [responseObject objectForKey:@"focusImages"];
        NSArray *arr = [dic objectForKey:@"list"];
        
        for (NSDictionary *dic in arr) {
            listModel *model = [[listModel alloc] initWithDic:dic];
            [self.myArr addObject:model];
            
        }
        _bannarView.picArr = self.myArr;
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
